package tenth.泛型方法;
class Info<T extends Number>{
    private T var;

    public T getVar() {
        return var;
    }

    public void setVar(T var) {
        this.var = var;
    }

    @Override
    public String toString() {
        return this.var.toString();
    }
}
public class 通过泛型方法返回泛型类实例 {
    public static void main(String[] args) {
        Info<Integer> i  = fun(30);
        System.out.println(i.getVar());
    }
    public static <T extends Number> Info<T> fun(T param){
        Info<T> i = new Info<>();
        i.setVar(param);
        return i;


    }
}
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=61084:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 tenth.泛型方法.通过泛型方法返回泛型类实例
30

Process finished with exit code 0

 */